<template>
  <nut-form>
    <nut-form-item label="姓名">
      <nut-input
        v-model="basicData.userName"
        class="nut-input-text"
        placeholder="请输入姓名"
        type="text"
      />
    </nut-form-item>
    <nut-form-item label="年龄">
      <nut-input
        v-model="basicData.password"
        class="nut-input-text"
        placeholder="请输入年龄"
        type="text"
      />
    </nut-form-item>
    <nut-cell>
      <nut-button size="small" style="margin-right: 10px" @click="handleLogin"
        >登录</nut-button
      >
    </nut-cell>
  </nut-form>
</template>
<script lang="ts" setup>
import { ref, reactive } from "vue";
import { login, getUserInfo } from "./../../api/user";
const basicData = reactive({
  userName: "",
  password: "",
});

const handleLogin = async () => {
  const { data }  = await login(basicData);
  uni.setStorageSync('token', data.token)
  getUserList()
};

const getUserList = async () => {
  const { data } = await getUserInfo({});
  console.log(data);
};
</script>